Module Overview
The Password Generator package provides three main components:list_elementsclass: Generates random selections from numbers or characterspassword_generator()function: Creates passwords from provided listspassword()function: High-level password generation with defaults
Classes
list_elements
A class that generates lists of random numbers or characters based on the input element.Constructor
The input element used for generating random selections. Can be:
- An integer: Used as the range for number generation (0 to element-1)
- A list: Used as the source for character selection
Methods
select_num()
Generates a list of 50 random numbers within the specified range.A list of 50 randomly selected numbers from the range [0, element). If an error occurs, prints an error message.
- Returns error message if the element value is less than 50
- Prints:
"Error generating list of numbers -> {error_details}"
select_char()
Randomly selects up to 5 unique characters from the provided list.A list of unique characters selected randomly from the element list, with a maximum of 5 characters. If an error occurs, prints an error message.
list(set(chars)) which removes duplicates, so the returned list may contain fewer than 5 characters if duplicates were selected.
Error Handling:
- Prints:
"Error generating character list -> {error_details}"
Functions
password_generator()
Generates a random 10-character password using the provided lists of numbers, strings, and special characters.Parameters
A list of numbers that can be used in the password generation process.
A list of strings (typically lowercase letters) that will be used to generate the password.
A list of special characters such as
!@#$%^&*().Returns
A randomly generated 10-character password combining elements from all three input lists. The password follows the pattern:
special_char + number + letter + special_char + UPPERCASE_letter + letter + number + letter + letter + special_charImplementation Details
- Generates 50 candidate passwords
- Ensures uniqueness by checking against previously generated passwords
- Randomly selects one password from the candidates
- One character is automatically uppercased (position 5)
- Prints:
"Error generating password -> {error_details}"
password()
High-level function that generates a password with predefined character sets and random selection parameters.Parameters
No parameters required. Uses internal defaults.Returns
A randomly generated 10-character password using:
- Numbers: 50 random numbers from range [51, 4000)
- Letters: 5 random lowercase letters from a-z
- Special characters: 5 random characters from the set
!"#$%&'()*+,-./:;<=>?@[]^_{|}~¡¿°€and backtick
Default Character Sets
The function uses these predefined sets:- Prints:
"Error in generating data collection to generate the password -> {error_details}"
Usage Flow
Here’s how the components work together:Module Information
Current version: 0.6
Edizon Alexander Meza Leal (edimez14@gmail.com)
Apache Software License 2.0
